/**
 * InfoFrameBase.java
 *
 * Roslan's Remake of MOO in 3D using Ardor3D
 * (C) 2011 Roslan Amir. All rights reserved.
 */

package com.roslan.games.moo3d.ui.hud;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ardor3d.extension.ui.UIFrame;
import com.ardor3d.extension.ui.UIFrameBar;
import com.ardor3d.extension.ui.UIPanel;
import com.ardor3d.extension.ui.backdrop.UIBackdrop;
import com.ardor3d.extension.ui.layout.RowLayout;
import com.ardor3d.extension.ui.util.SubTex;
import com.ardor3d.image.Texture;
import com.ardor3d.util.TextureManager;
import com.roslan.games.moo3d.Base;
import com.roslan.games.moo3d.GameData;

/**
 * The base class for all information panels.
 * 
 * @author Roslan Amir
 * @version 1.0 - Jan 17, 2011
 */
public abstract class InfoFrameBase extends UIFrame {

	/**
     * 
     */
	protected static final Logger logger = LoggerFactory.getLogger(Base.class);

	/**
	 * 
	 */
	protected static final String IMAGES_ALLOC_BUTTONS = "images/button_decr_incr.png";

	/**
	 * 
	 */
	protected static final SubTex[] SUBTEX_ALLOC_BUTTONS = new SubTex[4];

	/*
	 * Load the image textures.
	 */
	static {
		/*
		 * Load the button image textures.
		 */
		final Texture tex = TextureManager.load(IMAGES_ALLOC_BUTTONS, Texture.MinificationFilter.Trilinear, false);
		SUBTEX_ALLOC_BUTTONS[0] = new SubTex(tex,  0, 0, 28, 20);
		SUBTEX_ALLOC_BUTTONS[1] = new SubTex(tex, 28, 0, 19, 20);
		SUBTEX_ALLOC_BUTTONS[2] = new SubTex(tex, 47, 0, 19, 20);
		SUBTEX_ALLOC_BUTTONS[3] = new SubTex(tex, 66, 0, 28, 20);
	}

	/**
	 * The <code>UIPanel</code> instance which is the main panel for all the widgets.
	 */
	protected final UIPanel infoPanel;

//	/**
//	 * The backdrop for the frame.
//	 */
//	protected UIBackdrop backDrop;

	/**
	 * The singleton instance.
	 */
	protected final GameData gameData = GameData.getInstance();

	/**
	 * Constructor.
	 * 
	 * @param title - the title of the frame
	 * @param backDrop - the backdrop to use
	 */
	public InfoFrameBase(String title, UIBackdrop backDrop) {
		super(title);
		this.setName(title);

		UIFrameBar titleBar = this.getTitleBar();
		titleBar.setFontStyles(HudManager.FONT_STYLES);
		titleBar.setMargin(HudManager.FRAME_INSETS);
		this.setUseStandin(true);
		this.setOpacity(0.9f);
//		backDrop = new SolidBackdrop(GameData.COLOR_CHOCOLATE);
		this.setBackdrop(backDrop);

		/*
		 * Create the Panel.
		 */
		infoPanel = new UIPanel();
		infoPanel.setLayout(new RowLayout(false));
		infoPanel.setPadding(HudManager.PADDING_2000);
		this.setContentPanel(infoPanel);

//		/*
//		 * Testing
//		 */
//		SkinManager.applyCurrentSkin(this);
	}

	/**
	 * Comment for method.
	 */
	protected void updateAndpack() {
		this.layout();
		this.updateMinimumSizeFromContents();
		this.pack();
	}

}
